package cn.piesat.dao;

import cn.piesat.dto.PiesatRoleMenuDTO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface PiesatRoleMenuDAO extends JpaRepository<PiesatRoleMenuDTO,String> {
    @Query(nativeQuery = true,value = "select d.* from piesat_role_menu_relation d where d.menu_id not in(select c.pid from(select b.PID from piesat_role_menu_relation a left join piesat_menu_info b on a.MENU_ID = b.ID where b.pid is not null ) c) and role_id =?1")
    List<PiesatRoleMenuDTO> findByRoleId(String id);

    void deleteByRoleId(String id);

    void deleteAllByMenuIdIn(List<String> menuId);
}
